package com.cyj.dream.admin.contacts.enums;


import com.cyj.dream.admin.util.IsEmptyUtils;

/**
 * @Description: 菜单模块枚举值
 * @BelongsProject: dream-DreamChardonnay
 * @BelongsPackage: com.dream.DreamChardonnay.constant.enums
 * @Author: ChenYongJia
 * @CreateTime: 2021-05-06 09:48
 * @Email: chen87647213@163.com
 * @Version: 1.0
 */
public enum ModuleEnum {

    /**
     * 用户类型(0:根节点菜单)
     */
    MODULE_PARENT((long) 0, "根节点菜单"),
    ;

    private Long code;
    private String message;

    ModuleEnum(Long code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 根据 类型编码 来获取 描述信息
     *
     * @param code
     * @return
     */
    public static String getMessByCode(Integer code) {
        if (IsEmptyUtils.isEmpty(code)) {
            return null;
        }

        for (ModuleEnum moduleEnum : values()) {
            if (moduleEnum.getCode().equals(code)) {
                return moduleEnum.getMessage();
            }
        }
        throw new RuntimeException("没有找到对应的描述信息");
    }

    public Long getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static void main(String[] args) {
        System.out.println(ModuleEnum.MODULE_PARENT);
    }

}
